//
//  ArroundSectiondTableViewCell.m
//  GoShops
//
//  Created by zcj on 15-12-7.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//

#import "ArroundSectiondTableViewCell.h"
#import "Grouble.h"

@implementation ArroundSectiondTableViewCell

+(instancetype)ArroundSectiondTableViewCell:(UITableView *)tableView cityArray:(NSArray *)cityArray;
{
    static NSString *ID = @"arroundsectiondtablecell";
    ArroundSectiondTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[ArroundSectiondTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID cityArray:cityArray];
    }
    // 设置不能选中,选中每反应
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cityArray:(NSArray *)cityArray;
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat margen = 10;
        NSString * aroundName = @"周边旅游城市";
        CGSize arroundSize = [aroundName sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}];
        
        UILabel * arround = [[UILabel alloc]initWithFrame:CGRectMake(margen, margen, arroundSize.width, arroundSize.height)];
        arround.font = [UIFont systemFontOfSize:13];
        arround.textAlignment = NSTextAlignmentJustified;
        arround.text = aroundName;
        arround.textColor = [UIColor blackColor];
        [self addSubview:arround];
        
        //搞一个下划线
        UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 3 * margen, ScreenWidth, 0.5)];
    
        lineView.backgroundColor = ZCJColor(192, 192, 192);
        [self addSubview:lineView];
        
        CGFloat backX  = margen;
        CGFloat backY = 4 * margen;
        CGFloat backW = ScreenWidth - 2 * margen;
        CGFloat backH = 100;
        UIView * backCity = [[UIView alloc]initWithFrame:CGRectMake(backX, backY, backW, backH)];
        
        backCity.backgroundColor = [UIColor whiteColor];
        [self addSubview:backCity];
        
        
        CGFloat citylabelW = backW/ 4;
        CGFloat cityLableH = backH * 0.5;
        for (int i = 0; i < 8; i ++) {
            UILabel * cityLable = [[UILabel alloc]init];
            if (i < 4) {
                cityLable.frame = CGRectMake(i * citylabelW, 0, citylabelW, cityLableH);
            }else{
                cityLable.frame = CGRectMake((i-4) * citylabelW, cityLableH, citylabelW, cityLableH);
            }
            cityLable.font = [UIFont systemFontOfSize:15];
            cityLable.textAlignment = NSTextAlignmentCenter;
            cityLable.layer.borderWidth = 0.25;
            cityLable.layer.borderColor = [ZCJColor(255, 255, 255)  CGColor];
            cityLable.text = [cityArray[i] objectForKey:@"name"];
            [backCity addSubview:cityLable];
        }
        // Initialization code
    }
    return self;
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
